package com.xiaojf.xlog.appender.file.configure;

import com.xiaojf.xlog.appender.AccessLogAppender;
import com.xiaojf.xlog.appender.file.AccessLogFileAppender;
import com.xiaojf.xlog.aspect.AccessLogAspect;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * rdb 保存访问日志配置
 *
 * @author Ade.Xiao 2021/3/12 13:42
 */
@ConditionalOnMissingBean(AccessLogAppender.class)
@ConditionalOnProperty(prefix = "xlog.access", name = "appender-type", havingValue = "file")
@Configuration
public class AccessLogFileAppenderConfigure {
    /**
     * 文件形式记录访问日志
     *
     * @return {@link AccessLogAspect}
     * @author Ade.Xiao 2021-03-11 14:36:19
     */
    @Bean
    @Primary
    public AccessLogAppender accessLogAppender() {
        return new AccessLogFileAppender();
    }
}
